package no.ntnu.fp.su;

import no.ntnu.fp.su.sensors.ErosionProbe;
import no.ntnu.fp.su.sensors.PressureSensor;
import no.ntnu.fp.su.sensors.TemperatureSensor;

/**
 * A petroleum well with two sand erosion probes, a temperature sensor and a pressure sensor.
 * 
 * The only thing needed to get data for WATCH is to call the sample() method of this class
 * once every second. This will return the values R0, R1, T0 and P0 as an array of double values,
 * and will advance the simulation 1 second.
 *
 */
public class Well {
	private ErosionProbe e1;
	private ErosionProbe e2;
	private TemperatureSensor t1;
	private PressureSensor p1;
	private Flow flow;
	/**
	 * Creates a new simulated well.
	 */
	public Well() {
		flow = new Flow();
		e1=new ErosionProbe(flow,200);
		e2=new ErosionProbe(flow,100);
		t1=new TemperatureSensor(flow,150);
		p1=new PressureSensor(flow);
	}
	public Flow getFlow() {
		return flow;
	}
	/**
	 * Returns a set of readings from the flow. The format is:
	 * [ R0 from upper erosion probe | R1 from lower erosion probe | T0 from temperature sensor | P0 from pressure sensor ]
	 * 
	 * Every time this method is called, the simulation advances 1 second.
	 */
	public double[] sample() {
		double[] readings = new double[] {e1.sample(), e2.sample(), p1.sample(),t1.sample()};
		flow.tick();
		return readings;
	}
}
